#include "filecommandcreatortest.h"
#include "filecommandcreator.h"
#include "messagepack.h"
#include "cdcommand.h"

FileCommandCreatorTest::FileCommandCreatorTest()
{
}

void FileCommandCreatorTest::creatorTypeTest()
{
	int seq = 1;
	boost::shared_ptr<MessagePack> messagePack = MessagePack::createMessagePack(CDCommandCode);
	messagePack->appendData("Dir", "c:\\");
	messagePack->appendData("Seq", seq);
	QByteArray messData = messagePack->marshal();

	boost::shared_ptr<FileBrowserCommand> command = RestoreFileCommand(messData);
	QTEST_ASSERT(command.get() != NULL);
	QString reponseData;
	command->doCommand(reponseData);
	QVERIFY(typeid(*command) == typeid(CDCommand));
	QVERIFY(command->getSeq() == seq);

	messagePack->setCode(InvalidCode);
	messData = messagePack->marshal();

	command = RestoreFileCommand(messData);
	QVERIFY(command.get() == NULL);
}
